package com.hualan.dao.impl;

import com.hualan.bean.PanghuShop;
import com.hualan.bean.PanghuShopGoods;
import com.hualan.dao.ShopGoodsList;
import com.hualan.utils.C3P0Util;

import java.util.List;

public class ShopGoodsListImpl implements ShopGoodsList {
    @Override
    public List<PanghuShopGoods> selectShopGoodsAll(int page,int size) {
        List<PanghuShopGoods> list = C3P0Util.query("select * from panghu_shop_goods limit ?,?", PanghuShopGoods.class,(page-1)*size,size);
        for (PanghuShopGoods p : list) {
            PanghuShop panghuShop = selectById(p.getShopId());
            p.setGoodsShopName(panghuShop.getShopName());
        }
        return list;
    }

    @Override
    public PanghuShop selectById(int id) {
        PanghuShop panghuShop = C3P0Util.queryOne("select * from panghu_shop where shop_id=?", PanghuShop.class, id);
        return panghuShop;
    }
}
